Java is a programming language invented by Sun Microsystems, Inc. Applications developed using the Java language can be run on any platform equipped with a Java Virtual Machine (JVM). Applications written with Java cannot match the performance of applications written in C/C++ and compiled directly into a native code. Several techniques to reduce the performance gap have been developed. However, while the techniques are successful in terms of narrowing the performance gap, the success is at the cost of extra memory foot-print or a lack of compatibility to past designs.
There are several major factors contributing to the lack of performance. Two of the larger factors are the need to perform garbage collection and the stack machine nature of the JVM. Garbage collection can constitute about 20–30% of the overall processing, while Java instruction execution uses the rest, including thread synchronization. Garbage collection consumes a substantial part of the total computing resources of the JVM. Performance could be improved by reducing the MIPS count for the garbage collection.
However, the largest factor contributing to the slow performance is the execution of the Java instructions. The execution of Java instructions uses a stack based architecture. The stack based architecture is well known for having a compact code size. However, the stack based architecture is also notoriously known for poor performance. Such an architecture reduces the options for compiler optimizations, and for runtime optimizations (such as using several functional units, as is done with super-scalar machines).
Conventional JVMs implement the stack using either memory or dedicated registers. When there is no special hardware (i.e., a software JVM is implemented on an ordinary processor), memory is used for stack storage. A JVM using memory for stack storage has a severe disadvantage. Most processors are register machines, while JVM is a stack machine. In order to execute JVM instruction arguments, the arguments must be transferred from the JVM stack in memory into processor registers. The need to transfer stack contents from memory to processor registers can introduce additional native instructions. In addition, memory transfer can be a slow operation.
A dedicated set of registers can be used as a top of JVM stack. Dedicated registers are used in hardware versions of JVM, like picoJava™ from Sun. The main drawback of using dedicated registers is that the processor must have a dedicated register stack and special instructions for manipulating the stack. Most of available processors do not have the dedicated register stack or the special instructions.
It would be desirable to have an apparatus and/or method for providing fast JAVA bytecode execution with a very low memory footprint and without requiring rewriting of code that (i) uses the internal registers of a general purpose processor as a Java virtual machine (JVM) top of stack and (ii) dynamically allocates the registers according to stack status.